package cn.lavender.web.configuration.http;

import cn.lavender.web.response.api.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Slf4j
@Component
public class TestCommandLlineRunner implements CommandLineRunner {

    @Autowired
    private RestTemplate restTemplate;

    @Override
    public void run(String... args) throws Exception {
        String interfaceUrl = "http://ip:port/context";
        log.info("Task-service invoke manager-service interfaceUrl is {}.", interfaceUrl);
        // 定义返回值类型，则restTemplate#exchange返回值直接被转掉了
        ParameterizedTypeReference<ApiResponse> responseType = new ParameterizedTypeReference<ApiResponse>() {
        };
        //ResponseEntity<ApiResponse> responseResponseEntity = restTemplate.exchange(interfaceUrl, HttpMethod.POST, null, responseType);
        //ApiResponse apiResponse = responseResponseEntity.getBody();
    }

}
